// pages/parent-course/list.js
//家长课堂
var course = require('../index/model/CourseIndex.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    courses:[],
    pageNum:1,
    pageCount:10,
    _currentGradeLevel:-1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that=this
    var gradeLevel = options.gradeLevel
    this.setData({
      _currentGradeLevel:gradeLevel
    })
    course.getCourse("3", gradeLevel, "1", null, null, this.data.pageNum, this.data.pageCount, function(list){
      that.setData({
        courses: list
      })
    })
  },
  onCourseItemClick:function(event){
    var position = event.detail.position
    var id = event.detail.courseNo
    var title = event.detail.title
    var _url = '../courseinfo/detail?courseId=' + id + '&title=' + title
    wx.navigateTo({
      url: _url,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    var that = this
    var index = this.data.pageNum + 1
    course.getCourse("3", this.data._currentGradeLevel, "1", null, null, index, this.data.pageCount, function (list) {
      that.setData({
        courses: list,
        pageNum: index
      })
    })
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})